package com.schedule.teacher.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.schedule.teacher.entity.Teacher;
import com.schedule.teacher.entity.TeacherParam;
import com.schedule.teacher.mapper.TeacherMapper;
import com.schedule.teacher.service.TeacherService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

@Service
public class TeacherServiceImpl extends ServiceImpl<TeacherMapper, Teacher> implements TeacherService {
    @Override
    public IPage<Teacher> getList(TeacherParam param) {
        //构造分页对象
        IPage<Teacher> page = new Page<>();
        page.setSize(param.getPageSize());
        page.setCurrent(param.getCurrentPage());
        //构造查询条件
        QueryWrapper<Teacher> query = new QueryWrapper<>();
        if(StringUtils.isNotEmpty(param.getTeacherName())){
            query.lambda().like(Teacher::getTeacherName,param.getTeacherName());
        }
        return this.baseMapper.selectPage(page,query);
    }
}
